setwd("/Users/js4693/Dropbox/Works_in_Progress/LSS State Courts/SupremeCourtExperiment/Code and Data for Submission/Data for Submission")
library(tidyverse)
library(ggplot2)
library(dplyr)
library(gtable)
library(gridExtra)
library(grid)
library(ggpubr)
##############################################################
##############################################################
#######################################
### !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ###
##### set the working directory! ######
setwd("~/Dropbox/Shop\ Around/SupremeCourtExperiment/Code\ and\ Data\ for\ Submission/Data\ for\ Submission/")
get_legend<-function(myggplot){
tmp <- ggplot_gtable(ggplot_build(myggplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)
}
# Generate 84% confidence intervals - Julious (2004) - 5%
# alpha
alpha <- 1-.84
# confidence intervals
CI_intervals.l <- alpha/2
CI_intervals.u <- 1- alpha/2
# generate Z critical value
qnorm(CI_intervals.u,mean = 0, sd = 1)
# Generate 84% confidence intervals - Julious (2004) - 10%
# alpha
alpha_10 <- 1-0.76
# confidence intervals
CI_intervals.l10 <- alpha_10/2
CI_intervals.u10 <- 1- alpha_10/2
# generate Z critical value
qnorm(CI_intervals.u10,mean = 0, sd = 1)
# read in data for just DV-Treatment plots
OG_AARacialResentTherm <- read.table("OG_AA_RacialResentment",
header = TRUE,
sep = "",
dec = ".")
# separate gender from race
OG_AARRThermBlack <- OG_AARacialResentTherm %>% filter(respType=="black")
# make treatment factor
OG_AARRThermBlack$treatment<- as.factor(OG_AARRThermBlack$treatment)
is.factor(OG_AARRThermBlack$treatment)
View(OG_AARacialResentTherm)
View(OG_AARRThermBlack)
# order treatment
OG_AARRThermBlack$treatment.ordered <- factor(OG_AARRThermBlack$treatment, levels=c("control", "WM", "WF", "BF", "BM"))
# reorder legend items
OG_AARRThermBlack$identity <- as.factor(OG_AARRThermBlack$identity)
is.factor(OG_AARRThermBlack$identity)
OG_AARRThermBlack$identity <- factor(OG_AARRThermBlack$identity, levels=c("Low", "Median", "High"))
## error bar for 84% confidence interval
OG_AARRThermBlack$LB_84 <- OG_AARRThermBlack$margin - (1.405*OG_AARRThermBlack$StdEr)
OG_AARRThermBlack$UB_84 <- OG_AARRThermBlack$margin + (1.405*OG_AARRThermBlack$StdEr)
# race therm plot - APPENDIX FIGURE A6 RIGHT PANEL
OG_AARRThermBlackPlot <- ggplot(data = OG_AARRThermBlack, aes(x = treatment.ordered, y = margin, shape = identity, colour = identity)) +
geom_point(aes(shape = identity, colour = identity), size = 4, position=position_dodge(width=0.3)) +
geom_pointrange(aes(ymin= LB_84, ymax= UB_84), width=0.2, size=1, position=position_dodge(width=0.3)) +
scale_colour_grey(start = 0, end = 0.65) +
labs(colour="Racial Resentment",linetype="Racial Resentment",shape="Racial Resentment") +
xlab("Affirmative Action Treatment") +
scale_x_discrete(labels = c("Control", "White\nMale", "White\nFemale", "Black\nFemale", "Black\nMale")) +
ylab("Participants' Feelings Towards the Supreme Court\n(0-100 Thermometer)") +
scale_y_continuous(breaks = seq(0, 120, 20),
limits = c(0, 120)) +
#geom_hline(yintercept = 0, size = 1, colour = "red") +
theme_bw() +
theme(panel.grid.major = element_line(colour = "gray75"),
panel.grid.minor = element_line(colour = "white")) +
theme(axis.text.x = element_text(size=12)) +
theme(axis.text.y = element_text(size=12)) +
theme(axis.title = element_text(size = 14)) +
theme(legend.text=element_text(size=12, color = "gray20")) +
theme(legend.title=element_text(size=14)) +
ggtitle("Affirmative Action by Racial Resentment of Black Participants") +
theme(plot.title = element_text(color="black", size=18, face="bold")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="bottom")
OG_AARRThermBlackPlot
# separate gender from race
OG_AARRThermWhite <- OG_AARacialResentTherm %>% filter(respType=="white")
# make treatment factor
OG_AARRThermWhite$treatment<- as.factor(OG_AARRThermWhite$treatment)
is.factor(OG_AARRThermWhite$treatment)
# order treatment
OG_AARRThermWhite$treatment.ordered <- factor(OG_AARRThermWhite$treatment, levels=c("control", "WM", "WF", "BF", "BM"))
# reorder legend items
OG_AARRThermBlack$identity <- as.factor(OG_AARRThermBlack$identity)
is.factor(OG_AARRThermBlack$identity)
OG_AARRThermBlack$identity <- factor(OG_AARRThermBlack$identity, levels=c("Low", "Median", "High"))
## error bar for 84% confidence interval
OG_AARRThermWhite$LB_84 <- OG_AARRThermWhite$margin - (1.405*OG_AARRThermWhite$StdEr)
OG_AARRThermWhite$UB_84 <- OG_AARRThermWhite$margin + (1.405*OG_AARRThermWhite$StdEr)
# race therm plot - APPENDIX FIGURE A6 LEFT PANEL
OG_AARRThermWhitePlot <- ggplot(data = OG_AARRThermWhite, aes(x = treatment.ordered, y = margin, shape = identity, colour = identity)) +
geom_point(aes(shape = identity, colour = identity), size = 4, position=position_dodge(width=0.3)) +
geom_pointrange(aes(ymin= LB_84, ymax= UB_84), width=0.2, size=1, position=position_dodge(width=0.3)) +
scale_colour_grey(start = 0, end = 0.65) +
labs(colour="Racial Resentment",linetype="Racial Resentment",shape="Racial Resentment") +
xlab("Affirmative Action Treatment") +
scale_x_discrete(labels = c("Control", "White\nMale", "White\nFemale", "Black\nFemale", "Black\nMale")) +
ylab("Participants' Feelings Towards the Supreme Court\n(0-100 Thermometer)") +
scale_y_continuous(breaks = seq(0, 120, 20),
limits = c(0, 120)) +
#geom_hline(yintercept = 0, size = 1, colour = "red") +
theme_bw() +
theme(panel.grid.major = element_line(colour = "gray75"),
panel.grid.minor = element_line(colour = "white")) +
theme(axis.text.x = element_text(size=12)) +
theme(axis.text.y = element_text(size=12)) +
theme(axis.title = element_text(size = 14)) +
theme(legend.text=element_text(size=12, color = "gray20")) +
theme(legend.title=element_text(size=14)) +
ggtitle("Affirmative Action by Racial Resentment of White Participants") +
theme(plot.title = element_text(color="black", size=18, face="bold")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="bottom")
OG_AARRThermWhitePlot
# APPENDIX FIGURE A6
OG_AARRThermPlotS <- grid.arrange(OG_AARRThermWhitePlot, OG_AARRThermBlackPlot,
ncol=2, nrow = 1)
rm(list=ls())
# Generate 84% confidence intervals - Julious (2004) - 5%
# alpha
alpha <- 1-.84
# confidence intervals
CI_intervals.l <- alpha/2
CI_intervals.u <- 1- alpha/2
# generate Z critical value
qnorm(CI_intervals.u,mean = 0, sd = 1)
# Generate 84% confidence intervals - Julious (2004) - 10%
# alpha
alpha_10 <- 1-0.76
# confidence intervals
CI_intervals.l10 <- alpha_10/2
CI_intervals.u10 <- 1- alpha_10/2
# generate Z critical value
qnorm(CI_intervals.u10,mean = 0, sd = 1)
# read in data for just DV-Treatment plots
OG_GCRacialResentTherm <- read.table("OG_GC_RacialResentment",
header = TRUE,
sep = "",
dec = ".")
# separate gender from race
OG_GCRRThermBlack <- OG_GCRacialResentTherm %>% filter(respType=="black")
# make treatment factor
OG_GCRRThermBlack$treatment<- as.factor(OG_GCRRThermBlack$treatment)
is.factor(OG_GCRRThermBlack$treatment)
# order treatment
OG_GCRRThermBlack$treatment.ordered <- factor(OG_GCRRThermBlack$treatment, levels=c("control", "WM", "WF", "BF", "BM"))
# reorder legend items
OG_GCRRThermBlack$identity <- as.factor(OG_GCRRThermBlack$identity)
is.factor(OG_GCRRThermBlack$identity)
OG_GCRRThermBlack$identity <- factor(OG_GCRRThermBlack$identity, levels=c("Low", "Median", "High"))
## error bar for 84% confidence interval
OG_GCRRThermBlack$LB_84 <- OG_GCRRThermBlack$margin - (1.405*OG_GCRRThermBlack$StdEr)
OG_GCRRThermBlack$UB_84 <- OG_GCRRThermBlack$margin + (1.405*OG_GCRRThermBlack$StdEr)
# race therm plot - APPENDIX FIGURE A7 RIGHT PANEL
OG_GCRRThermBlackPlot <- ggplot(data = OG_GCRRThermBlack, aes(x = treatment.ordered, y = margin, shape = identity, colour = identity)) +
geom_point(aes(shape = identity, colour = identity), size = 4, position=position_dodge(width=0.3)) +
geom_pointrange(aes(ymin= LB_84, ymax= UB_84), width=0.2, size=1, position=position_dodge(width=0.3)) +
scale_colour_grey(start = 0, end = 0.65) +
labs(colour="Racial Resentment",linetype="Racial Resentment",shape="Racial Resentment") +
xlab("Gun Control Treatment") +
scale_x_discrete(labels = c("Control", "White\nMale", "White\nFemale", "Black\nFemale", "Black\nMale")) +
ylab("Participants' Feelings Towards the Supreme Court\n(0-100 Thermometer)") +
scale_y_continuous(breaks = seq(0, 120, 20),
limits = c(0, 120)) +
#geom_hline(yintercept = 0, size = 1, colour = "red") +
theme_bw() +
theme(panel.grid.major = element_line(colour = "gray75"),
panel.grid.minor = element_line(colour = "white")) +
theme(axis.text.x = element_text(size=12)) +
theme(axis.text.y = element_text(size=12)) +
theme(axis.title = element_text(size = 14)) +
theme(legend.text=element_text(size=12, color = "gray20")) +
theme(legend.title=element_text(size=14)) +
ggtitle("Gun Control by Racial Resentment of Black Participants") +
theme(plot.title = element_text(color="black", size=18, face="bold")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="bottom")
OG_GCRRThermBlackPlot
# separate gender from race
OG_GCRRThermWhite <- OG_GCRacialResentTherm %>% filter(respType=="white")
# make treatment factor
OG_GCRRThermWhite$treatment<- as.factor(OG_GCRRThermWhite$treatment)
is.factor(OG_GCRRThermWhite$treatment)
# order treatment
OG_GCRRThermWhite$treatment.ordered <- factor(OG_GCRRThermWhite$treatment, levels=c("control", "WM", "WF", "BF", "BM"))
# reorder legend items
OG_GCRRThermWhite$identity <- as.factor(OG_GCRRThermWhite$identity)
is.factor(OG_GCRRThermWhite$identity)
OG_GCRRThermWhite$identity <- factor(OG_GCRRThermWhite$identity, levels=c("Low", "Median", "High"))
## error bar for 84% confidence interval
OG_GCRRThermWhite$LB_84 <- OG_GCRRThermWhite$margin - (1.405*OG_GCRRThermWhite$StdEr)
OG_GCRRThermWhite$UB_84 <- OG_GCRRThermWhite$margin + (1.405*OG_GCRRThermWhite$StdEr)
# race therm plot - APPENDIX FIGURE A7 LEFT PANEL
OG_GCRRThermWhitePlot <- ggplot(data = OG_GCRRThermWhite, aes(x = treatment.ordered, y = margin, shape = identity, colour = identity)) +
geom_point(aes(shape = identity, colour = identity), size = 4, position=position_dodge(width=0.3)) +
geom_pointrange(aes(ymin= LB_84, ymax= UB_84), width=0.2, size=1, position=position_dodge(width=0.3)) +
scale_colour_grey(start = 0, end = 0.65) +
labs(colour="Racial Resentment",linetype="Racial Resentment",shape="Racial Resentment") +
xlab("Gun Control Treatment") +
scale_x_discrete(labels = c("Control", "White\nMale", "White\nFemale", "Black\nFemale", "Black\nMale")) +
ylab("Participants' Feelings Towards the Supreme Court\n(0-100 Thermometer)") +
scale_y_continuous(breaks = seq(0, 120, 20),
limits = c(0, 120)) +
#geom_hline(yintercept = 0, size = 1, colour = "red") +
theme_bw() +
theme(panel.grid.major = element_line(colour = "gray75"),
panel.grid.minor = element_line(colour = "white")) +
theme(axis.text.x = element_text(size=12)) +
theme(axis.text.y = element_text(size=12)) +
theme(axis.title = element_text(size = 14)) +
theme(legend.text=element_text(size=12, color = "gray20")) +
theme(legend.title=element_text(size=14)) +
ggtitle("Gun Control by Racial Resentment of White Participants") +
theme(plot.title = element_text(color="black", size=18, face="bold")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="bottom")
OG_GCRRThermWhitePlot
# APPENDIX FIGURE A7
OG_GCRRThermPlots <- grid.arrange(OG_GCRRThermWhitePlot, OG_GCRRThermBlackPlot,
ncol=2, nrow = 1)
View(OG_GCRacialResentTherm)
View(OG_GCRRThermBlack)
View(OG_GCRRThermWhite)
View(OG_GCRacialResentTherm)
View(OG_GCRRThermBlack)
View(OG_GCRacialResentTherm)
# read in data for just DV-Treatment plots
OG_AARacialResentTherm <- read.table("OG_AA_RacialResentment",
header = TRUE,
sep = "",
dec = ".")
View(OG_AARacialResentTherm)
